package com.ruoyi.platform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.platform.domain.TbVehicle;
import com.ruoyi.platform.service.ITbVehicleService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车机端更新Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/vehicle")
public class TbVehicleController extends BaseController
{
    @Autowired
    private ITbVehicleService tbVehicleService;

    /**
     * 查询车机端更新列表
     */
    //@RequiresPermissions("platform:vehicle:list")
    @GetMapping("/list")
    public TableDataInfo list(TbVehicle tbVehicle)
    {
        startPage();
        List<TbVehicle> list = tbVehicleService.selectTbVehicleList(tbVehicle);
        return getDataTable(list);
    }

    /**
     * 导出车机端更新列表
     */
    //@RequiresPermissions("platform:vehicle:export")
    @Log(title = "车机端更新", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVehicle tbVehicle)
    {
        List<TbVehicle> list = tbVehicleService.selectTbVehicleList(tbVehicle);
        ExcelUtil<TbVehicle> util = new ExcelUtil<TbVehicle>(TbVehicle.class);
        util.exportExcel(response, list, "车机端更新数据");
    }

    /**
     * 获取车机端更新详细信息
     */
    //@RequiresPermissions("platform:vehicle:query")
    @GetMapping(value = "/{driverId}")
    public AjaxResult getInfo(@PathVariable("driverId") Long driverId)
    {
        return success(tbVehicleService.selectTbVehicleByDriverId(driverId));
    }

    /**
     * 新增车机端更新
     */
    //@RequiresPermissions("platform:vehicle:add")
    @Log(title = "车机端更新", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVehicle tbVehicle)
    {
        return toAjax(tbVehicleService.insertTbVehicle(tbVehicle));
    }

    /**
     * 修改车机端更新
     */
    //@RequiresPermissions("platform:vehicle:edit")
    @Log(title = "车机端更新", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVehicle tbVehicle)
    {
        return toAjax(tbVehicleService.updateTbVehicle(tbVehicle));
    }

    /**
     * 删除车机端更新
     */
    //@RequiresPermissions("platform:vehicle:remove")
    @Log(title = "车机端更新", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverIds}")
    public AjaxResult remove(@PathVariable Long[] driverIds)
    {
        return toAjax(tbVehicleService.deleteTbVehicleByDriverIds(driverIds));
    }
}
